<template>
    <div>
        <h1>账号管理登录界面</h1>
        <table class="table">
            <tbody>
                <tr>
                <td>账号</td>
                <td>
                    <input type="text" v-model="data.name">
                </td>
            </tr>
            <tr>
                <td>密码</td>
                <td>
                    <input type="password" v-model="data.password">
                </td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <input type="button" value="登录" @click="Login" >
                </td>
            </tr>
            </tbody>
          
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref } from 'vue';
import { useRouter } from 'vue-router';

const router=useRouter();
const data=ref({
    "id": 0,
  "name": "admin",
  "password": "",
  "memberName": "张三",
  "phone": "18298977638",
  "memberType": "机构管理员",
  "people": "孙悟空"
})

//登录
const Login=()=>{
    if(data.value.name==""){
        alert('账号不能为空');
        return;
    }
    if(data.value.password==""){
        alert('密码不能为空');
        return;
    }
    axios.get("https://localhost:7067/api/Member/Login",{params:data.value}).then(res=>{
        if(res.data.id==-1){
            alert('账号有误');
            return;
        }
        if(res.data.id==-2){
            alert('密码有误');
            return;
        }
        if(res.data.id>0){
            alert('登录成功');
            router.push({path:"/Show1"});
        }
    })
}

</script>

<style scoped>

</style>